﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace DGIS.Model
{
    /// <summary>
    /// 下载文件实体
    /// </summary>
    public class DownloadFile:INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// 图标
        /// </summary>
        private ImageSource iconSource;

        /// <summary>
        /// 文件名称
        /// </summary>
        private string fileName;

        /// <summary>
        /// 文件大小(字节)
        /// </summary>
        private double fileSize;

        /// <summary>
        /// 当前进度
        /// </summary>
        private double progressValue;

        /// <summary>
        /// 下载速度
        /// </summary>
        private double speed;

        /// <summary>
        /// 任务状态
        /// </summary>
        private Int64 status;

        /// <summary>
        /// 任务指针
        /// </summary>
        public IntPtr TaskIntPtr { get; set; }

        public ImageSource IconSource
        {
            get { return iconSource; }
            set
            {
                iconSource = value;
                this.ProgressPropertyChanged("IconSource");
            }
        }

        public string FileName
        {
            get { return fileName; }
            set
            {
                fileName = value;
                this.ProgressPropertyChanged("FileName");
            }
        }

        public double FileSize
        {
            get { return fileSize; }
            set
            {
                fileSize = value;
                this.ProgressPropertyChanged("FileSize");
            }
        }

        public double ProgressValue
        {
            get { return progressValue; }
            set
            {
                progressValue = value;
                this.ProgressPropertyChanged("ProgressValue");
            }
        }

        public string DataId { get; set; }

        public string Url { get; set; }

        public string SavePath { get; set; }

        public double Speed
        {
            get { return speed; }
            set
            {
                speed = value;
                this.ProgressPropertyChanged("Speed");
            }
        }

        public Int64 Status
        {
            get { return status; }
            set
            {
                status = value;
                this.ProgressPropertyChanged("Status");
            }
        }


        private void ProgressPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public enum DownloadStatus
        {
            Downloading,//下载中
            Error,//错误
            Stop,//停止
            Complete//完成
        }
    }
}
